package com.lazyfish.superdir.dao;

import com.lazyfish.superdir.entity.Dir;
import org.apache.ibatis.annotations.*;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
@Primary
public interface DirDao {
    @Select("SELECT COUNT(*) FROM Dir_new")
    int getTotal();
    @Select("SELECT * FROM Dir_new WHERE id = #{id}")
    Dir getDir(int id);
    @Select("SELECT * FROM Dir_new")
    List<Dir> getDirList();
    @Insert("INSERT INTO Dir_new (name,intro,fieldData) VALUES (#{name},#{intro},#{fieldData})")
    int makeDir(Dir dir);
    @Update("UPDATE Dir_new SET collect=#{collect} WHERE id=#{id}")
    int updateDirCollection(@Param("collect") int collect,@Param("id") int id);
    @Delete("DELETE FROM Dir_new WHERE id=#{id}")
    int deleteDir(int id);
    @Update("UPDATE Dir_new SET name = #{name} ,intro = #{intro},fieldData = #{fieldData} where id =#{id}")
    int modifyDir(Dir dir);
}
